package com.heima.common.tess4j;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.awt.image.BufferedImage;
@Configuration
public class Tess4jClient {

    @Autowired
    private ITesseract tesseract;

    /***
     * 传入图片实现图片检测
     */
    public String doOCR(BufferedImage image) throws Exception{
        //3)图片识别
        String content = tesseract.doOCR(image);
        return content;
    }

    @Bean
    public ITesseract tesseract(){
        ITesseract tesseract = new Tesseract();
        //配置相关属性   字体路径、字体语言
        tesseract.setDatapath("E:/code148");
        tesseract.setLanguage("chi_sim");
        return tesseract;
    }
}